using System.IO;
using System.Text;

namespace IllSoft.Xvcc.Volano.Client
{
    internal class VolanoWriter : BinaryWriter
    {
        public VolanoWriter()
            : base()
        {
        }

        public VolanoWriter(Stream output)
            : base(output)
        {
        }

        public VolanoWriter(Stream output, Encoding encoding)
            : base(output, encoding)
        {
        }

        public void Write(params byte[][] buffer)
        {
            foreach (byte[] x in buffer)
            {
                base.Write(x);
            }
        }

        public void Write(params string[] value)
        {
            byte[] data;

            foreach (string x in value)
            {
                data = Encoding.UTF8.GetBytes(x);

                this.WriteLength(data);
                this.Write(data);
            }
        }

        private void WriteLength(byte[] data)
        {
            this.Write((byte)(data.Length / 0x100));
            this.Write((byte)(data.Length % 0x100));
        }
    }
}